import request from '@/utils/request';

/**
 * 分页查询报关运费
 */
export async function pageApplyCustomsFee(params) {
  const res = await request.get('/order/applyCustomsFee/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询报关运费列表
 */
export async function listApplyCustomsFee(params) {
  const res = await request.get('/order/applyCustomsFee', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询报关运费
 */
export async function getApplyCustomsFee(id) {
  const res = await request.get('/order/applyCustomsFee/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加报关运费
 */
export async function addApplyCustomsFee(data) {
  const res = await request.post('/order/applyCustomsFee', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改报关运费
 */
export async function updateApplyCustomsFee(data) {
  const res = await request.put('/order/applyCustomsFee', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除报关运费
 */
export async function removeApplyCustomsFee(id) {
  const res = await request.delete('/order/applyCustomsFee/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
